/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.platformservice.persistence.c14n;

import org.proteusframework.platformservice.persistence.messagebean.DataType;

/**
 * @author Tacoma Four
 */
abstract class AbstractC14NHandler implements IC14NHandler
{
    protected int transposeClassName(String className)
    {
        // For encoding details, review the JLS or SDK JavaDocs for Class#getName()
        if (className.equals("[Z"))
        {
            return DataType.BooleanArrayType.ordinal();
        } else if (className.equals("[D"))
        {
            return DataType.DoubleArrayType.ordinal();
        } else if (className.equals("[F"))
        {
            return DataType.FloatArrayType.ordinal();
        } else if (className.equals("[I"))
        {
            return DataType.IntegerArrayType.ordinal();
        } else if (className.equals("[J"))
        {
            return DataType.LongArrayType.ordinal();
        } else if (className.equals("[S"))
        {
            return DataType.ShortArrayType.ordinal();
        } else if (className.equals("[Ljava.lang.String;"))
        {
            return DataType.StringArrayType.ordinal();
        } else if (className.equals("[Ljava.util.Date;"))
        {
            return DataType.DateArrayType.ordinal();
        } else
        {
            throw new IllegalStateException("C14N handler cannot yet handle encoding object arrays: " + className);
        }
    }

}
